﻿using FlowCanvas;
using ParadoxNotion;
using UnityEngine;

namespace Yoozoo.Gameplay.Liberty.Nodes
{
    public class PlayerBoxTrigger : BoxTrigger
    {
        public override string name
        {
            get
            {
                return string.Format("{0} ({1})", "PlayerBoxTrigger", pointName.value);
            }
        }

        protected override void RegisterPorts()
        {
            AddFlowInput("start", OnStart);

            onEnter = AddFlowOutput("Enter");
            onStay = AddFlowOutput("Stay");
            onExit = AddFlowOutput("Exit");
        }

        protected override void OnTriggerEnterFunc(EventData<Collider> msg)
        {
            if (BlueprintUtils.IsPlayerTriggerCollider(msg.value))
            {
                onEnter.Call(new Flow());
            }
        }

        protected override void OnTriggerStayFunc(EventData<Collider> msg)
        {
            if (BlueprintUtils.IsPlayerTriggerCollider(msg.value))
            {
                onStay.Call(new Flow());
            }
        }

        protected override void OnTriggerExitFunc(EventData<Collider> msg)
        {
            if (BlueprintUtils.IsPlayerTriggerCollider(msg.value))
            {
                onExit.Call(new Flow());
            }
        }
    }
}